class GridBot(breve.Mobile):
	def __init__(self):
		breve.Mobile.__init__(self)
		self.handleCollisions('GridBot', 'botCollision')
	
	def iterate(self):
		breve.Mobile.iterate(self)
		self.neighborList = self.getNeighbors()	
		
	def botCollision(self):
		return 1
		
	def look(self, xDirection, zDirection, Type):
		x = 0
		z = 0
	
		if xDirection != "Center":
			if xDirection == "Left": x -= (self.unit - 1)
			else: x += (self.unit - 1)

		if zDirection != "Center":
			if zDirection == "Up": z -= (self.unit - 1)
			else: z += (self.unit - 1)
		
		while len(self.neighborList) > 0:
			neighbor = self.neighborList.pop()
			if (neighbor.getLocation()[0] > self.getLocation()[0] - self.unit / 2 + x and
			    neighbor.getLocation()[0] < self.getLocation()[0] - self.unit / 2 + self.unit + x and
			    neighbor.getLocation()[2] < self.getLocation()[2] + self.unit / 2 + z and
				neighbor.getLocation()[2] > self.getLocation()[2] + self.unit / 2 - self.unit + z):
					self.neighborList = self.getNeighbors()
					return isinstance(neighbor, Type)
		
		self.neighborList = self.getNeighbors()
		return False			
			
	def walk(self, xDirection, zDirection):
		x = 0
		z = 0
		
		if xDirection != "Center":
			if xDirection == "Left": x -= self.unit
			else: x += self.unit	
	
		if zDirection != "Center":
			if zDirection == "Up": z -= self.unit
			else: z += self.unit
	
		self.move(breve.vector(
			self.getLocation()[0] + x, 
			self.getLocation()[1], 
			self.getLocation()[2] + z))